const Router = require('koa-router')
const { Identity } = require('@/app/models/identity')
const { Auth } = require('@/middleware/auth')
const { NotEmptyValidator } = require('@/utils/validator')
const router = new Router({
  //统一这是前缀
  prefix: '/api/v1/identity' 
})
//新增标识  
router.post('/addIdentity',async ctx => {
  const v = await new NotEmptyValidator().validate(ctx,{
    token: 'name'
  })
  Identity.create({
    name: v.get('body.name')
  })
  ctx.body = global.responseData(null,'新增成功')
})
//查询标识  
router.get('/getIdentity',async ctx => {
  const identity = await Identity.findAll()
  ctx.body = global.responseData(identity)
})

module.exports = router